<template>
  <div>
    <el-menu
        class="el-menu-demo"
        mode="horizontal"
        background-color="#545c64"
        text-color="#fff"
        active-text-color="#ffd04b">
      <el-menu-item><router-link to="/">首页</router-link></el-menu-item>
      <el-menu-item><router-link to="/publish">发布</router-link></el-menu-item>
      <el-menu-item><router-link to="/mine">我的</router-link></el-menu-item>
      <el-menu-item disabled></el-menu-item>
      <el-menu-item disabled></el-menu-item>
      <el-menu-item disabled></el-menu-item>
      <el-menu-item disabled></el-menu-item>
      <el-menu-item disabled></el-menu-item>
      <el-menu-item disabled></el-menu-item>
      <el-menu-item disabled></el-menu-item>
      <el-menu-item disabled></el-menu-item>
      <el-menu-item disabled></el-menu-item>
      <el-menu-item disabled></el-menu-item>
      <el-menu-item disabled></el-menu-item>
      <el-menu-item disabled></el-menu-item>
      <el-menu-item disabled></el-menu-item>
      <el-menu-item disabled></el-menu-item>
      <el-menu-item disabled></el-menu-item>
      <el-menu-item disabled></el-menu-item>
      <el-menu-item disabled></el-menu-item>
      <el-menu-item disabled></el-menu-item>
      <el-menu-item disabled></el-menu-item>
      <el-menu-item disabled></el-menu-item>
      <el-menu-item disabled></el-menu-item>
      <el-menu-item disabled></el-menu-item>
      <el-menu-item disabled></el-menu-item>
      <el-menu-item disabled></el-menu-item>
      <el-menu-item disabled></el-menu-item>
      <el-menu-item disabled></el-menu-item>
    </el-menu>

    <el-card class="box-card">
      <el-form>
        <el-form-item>
          <el-input v-model="content"
          type="textarea"
          :autosize="{ minRows: 2, maxRows: 4}"
          placeholder="请输入内容">
          </el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary"  @click="handleSubmit">发布</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script>
export default {
  name: "Publish",
  data() {
    return {
      content: "",
    }
  },
  methods: {
    handleSubmit() {
      let user_id = sessionStorage.getItem('user_id');
      this.$http.post('/publish', [user_id, this.content]).then(res => {
        console.log(res);
        if(res.data != 'post ok')
          this.$message(res.data)
      }).catch(err => {
        console.log(err);
      })
      this.$router.push('/')
    }
  }
}
</script>

<style scoped>

</style>